package com.ynjt.client;

import com.ynjt.util.Decoder;
import com.ynjt.util.Encoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

public class ChatClientInitializer extends ChannelInitializer<SocketChannel> {

    private final ChatClient client;


    public ChatClientInitializer(ChatClient client) {
        this.client = client;
    }

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();

        pipeline.addLast(new Decoder());
        pipeline.addLast(new Encoder());
        pipeline.addLast(new ChatClientHandler(client));
    }
}
